<?php

namespace System\Core;

/**
 * @property enum $Tipo
 * @property System\Core\Config $Config
 */
final class ConfigItems
{

    private $_type;

    /**
     * @var System\Core\Config
     */
    private $_config;

    /**
     *
     * @param int $type
     * @param System\Core\Config $config
     */
    public function __construct($type, Config $config)
    {
        $type = (int) $type;

        $this->_config = $config;
        $this->_type = $type;
    }

    public function __get($name)
    {
        if ($name == 'Tipo')
            return $this->_type;
        else if ($name == 'Config')
            return $this->_config;

        return $this->Get($name);
    }

    /**
     * @param string $name
     * @return System\Core\ConfigItem
     */
    public function Get($name)
    {
        $_ = $this;

        return new \System\Core\ConfigItem($this->_type, $name, $_);
    }

    /**
     * @return int
     */
    public function Count()
    {
        return Config::Count($this->_type);
    }

    public function Add($key, $value)
    {
        return Config::Set($this->_type, $key, $value);
    }

}
